<?php
/**
 * 
 * Template Name: Contact
 * Author : vthanh_88
 * @package WordPress
*/
get_header();
wp_enqueue_script('validate');
if(have_posts()):the_post();
?>
  	
    <div class="wrapper">
        <?php get_sidebar(); ?>		 
        <div class="right-panel-outer">
			<div class="right-panel">
			   <div class="right-inner">
			   
                   <h2 class="head"><?php the_title(); ?></h2>		
					 
					 <?php
					 $contact_add_google_toppage = get_theme_option('contact','contact_add_google_toppage');
					 $google_map = get_theme_option('contact','google_map');
					 if($contact_add_google_toppage == 'true')
					 {
					    echo '<div>'.stripslashes($google_map).'</div>';
					 }
					 ?>
                     <p><?php the_content(); ?></p>
                          <div class="form-div">
                            <div id="sucessmessage" class="form-row"> </div>
                             <form id="contact_form" method="post" action="#">
                                    <div class="form-row">
                                        <label>Name</label>
                                        <input type="text" id="name" placeholder="First Name..." name="name">
                                    </div>  
                                    <div class="form-row">
                                        <label>Email</label>
                                        <input type="text" name="email" placeholder="Email..." id="email">
                                    </div>             
        						    <?php if(get_theme_option('contact','contact_enable_input_website') == 'true'): ?>                 
                                    <div class="form-row">
                                        <label>Website</label>
                                        <input type="text" id="website" name="website" placeholder="Website..." >
                                    </div>
        							<?php endif; ?>
        							<?php if(get_theme_option('contact','contact_enable_input_phone') == 'true'): ?>                 
                                    <div class="form-row">
                                        <label>Phone</label>
                                        <input type="text" id="phone" name="phone" placeholder="Phone..." >
                                    </div>
        							<?php endif; ?>
        							<?php if(get_theme_option('contact','contact_enable_input_address') == 'true'): ?>                 
                                    <div class="form-row">
                                        <label>Address</label>
                                        <input type="text" id="address" name="address" placeholder="Address..." >
                                    </div>
        							<?php endif; ?>
        							<div class="form-row">
                                        <label>Subject</label>
                                        <input type="text" name="subject" placeholder="Subject..." id="subject">
                                    </div>
                                    <div class="clearfix"></div>
                                    <div class="form-row wdh100">
                                        <label>Your Comments</label>
                                        <textarea name="comment" id="comment" placeholder="Your comments..."></textarea>
                                    </div>
									<div class="clearfix"></div>
        							<div class="form-row wdh100">
        							<?php
        								 the_recaptchar('contact');
        							?>
        							</div>
									<div class="clearfix"></div>
									<div class="form-row">
                                        <input type="submit" value="Submit" name="contact_submit" class="submit">
                                        <span class="get-back">We will get back to you within 24 hours !</span>
                                    </div>
									<div class="form-row">
                                        <p class="required-field">Field mark with * sign are required.</p>
                                    </div>
                                    <div class="clearfix"></div>
                            </form>
							
                        </div>
						<div class="clearfix"></div>
                   </div>
    	    </div>
			<div class="content-shadow">&nbsp;</div>
        </div>
        <div class="clearfix"></div>
    </div>
        	<?php
            else:
            ?>
    <div class="wrapper">
        <?php get_sidebar(); ?>		 
        <div class="right-panel-outer">
			<div class="right-panel">
			   <div class="right-inner">
                   <p>Sozzy. No Post for this pages.</p>
				   
   			   </div>
    	    </div>
			<div class="content-shadow">&nbsp;</div>
        </div>
        <div class="clearfix"></div>
    </div>
        
        <?php
        endif;
        ?>
<?php
	
	
	// CONTACT FORM VALIDATION
echo'<script type="text/javascript">
	jQuery(document).ready(function(){ 
		jQuery("#contact_form").validate({
			meta: "validate",
			submitHandler: function (form) {
			    jQuery("#contact_form").hide();
				var s_name=jQuery("#name").val();
				var s_email=jQuery("#email").val();
				var s_subject= jQuery("#subject").val();
				var s_comment=jQuery("#comment").val();';
				if(get_theme_option('contact','contact_enable_input_phone') == 'true'):
				   echo 'var s_phone=jQuery("#phone").val();';  
				endif;
				if(get_theme_option('contact','contact_enable_input_address') == 'true'):
				    echo 'var s_address=jQuery("#address").val();	';					  
				endif;
				if(get_theme_option('contact','$contact_enable_input_website') == 'true'):
				   echo 'var s_website=jQuery("#website").val();		';					  
				endif;
				if(get_theme_option('contact','contact_enable_recaptchar') == 'true' && is_user_must_using_captchar() == true):
                   echo 'var challengeField = jQuery("input#recaptcha_challenge_field").val();
                   var responseField = jQuery("input#recaptcha_response_field").val();';
				   		
				endif;
echo '
	  			data={
					 action : \'ajaxcontact\',
					 name: s_name,
					 email: s_email,
					 subject: s_subject,
					 comment: s_comment';
					 if(get_theme_option('contact','contact_enable_input_phone') == 'true'):
        			   echo ',phone:s_phone';  
        			 endif;					 
					 if(get_theme_option('contact','$contact_enable_input_website') == 'true'):
        			   echo ',website:s_website';  
        			 endif;					 
					 if(get_theme_option('contact','contact_enable_input_address') == 'true'):
        			   echo ',address:s_address';  
        			 endif;					 
					 if(get_theme_option('contact','contact_enable_recaptchar') == 'true'  && is_user_must_using_captchar() == true):
        			   echo ',recaptcha_challenge_field:challengeField';  
					   echo ',recaptcha_response_field:responseField';  
        			 endif;					 
echo'				};';				
echo '
				jQuery.post("'.admin_url('admin-ajax.php').'",data,
				function(result){
                  			jQuery("#sucessmessage").html(result);
                		});
				jQuery("#contact_form").hide();
				return false;
				},
				
				
			/* */
			rules: {
				name: "required",
			
				lastname: "required",
				// simple rule, converted to {required:true}
				email: { // compound rule
					required: true,
					email: true
				},
				subject: {
					required: true,
				},
				comment: {
					required: true
				}
			},
			messages: {
				name: "Please enter your name.",
				lastname: "Please enter your last name.",
				email: {
					required: "Please enter your email.",
					email: "Please enter your email."
				},
				subject: "Please enter your Subject.",
				comment: "Please enter your Comment."
			},
		});
	});		
</script>';	
	
?>
<?php
get_footer();  

?>
